import { Request, Response } from 'express';
import path from 'path';

export class TestController {
  /**
   * 主页测试页面
   */
  async index(req: Request, res: Response): Promise<void> {
    const serverInfo = {
      baseUrl: `http://localhost:${process.env.PORT || 3001}`,
      environment: process.env.NODE_ENV || 'development',
      database: 'MySQL with TypeORM',
      version: '1.0.0',
      uptime: process.uptime() > 60 ? `${Math.floor(process.uptime() / 60)}分钟` : `${Math.floor(process.uptime())}秒`,
    };

    res.render('pages/index', {
      title: '测试中心',
      subtitle: '完整的API功能测试平台',
      icon: 'fas fa-home',
      serverInfo,
      layout: 'layouts/main'
    });
  }

  /**
   * API测试页面
   */
  async apiTest(req: Request, res: Response): Promise<void> {
    res.render('pages/api', {
      title: 'API 测试',
      subtitle: '测试所有API端点的功能',
      icon: 'fas fa-code',
      layout: 'layouts/main'
    });
  }

  /**
   * 认证测试页面
   */
  async authTest(req: Request, res: Response): Promise<void> {
    res.render('pages/auth', {
      title: '认证测试',
      subtitle: 'JWT和Google OAuth认证测试',
      icon: 'fas fa-shield-alt',
      layout: 'layouts/main'
    });
  }

  /**
   * 支付测试页面
   */
  async paymentsTest(req: Request, res: Response): Promise<void> {
    res.render('pages/payments', {
      title: '支付测试',
      subtitle: 'Stripe支付和订阅功能测试',
      icon: 'fas fa-credit-card',
      layout: 'layouts/main'
    });
  }
} 